package com.course.controller;

import android.content.Context;

import com.baselib.android.cach.PreferceKey;
import com.baselib.android.cach.PreferceManager;
import com.baselib.android.utils.MD5Util;
import com.course.utils.web.HttpAction;
import com.course.utils.web.HttpReq;
import com.course.utils.web.HttpRespCallBack;
import com.course.utils.web.MapBuilder;

import org.apache.commons.lang3.StringUtils;

public class UserController {
    static UserController instance;

    public static UserController getInstance() {
        if (instance == null) {
            instance = new UserController();
        }
        return instance;
    }

    public void loginReg(String tel ,String pw, HttpRespCallBack httpRespCallBack){
        HttpReq.getInstance().post(HttpAction.loginReg.getValue(),
                new MapBuilder<String, Object>()
                        .add("tel", tel)
                        .add("pw", MD5Util.convertMD5(pw))
                        .getMap(),
                httpRespCallBack);
    }



    public boolean isLogin(Context context){
        String token = PreferceManager.getInsance().getValueBYkey(context, PreferceKey.TOKEN);
        return StringUtils.isNotBlank(token);
    }



}
